package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.Autofill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.function.LongFunction;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);


    /*
插入菜品
     */
@Autofill(value = OperationType.INSERT)
    void insert(Dish dish);


     Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

     @Delete("delete from sky_take_out.dish d where  d.id in (#{id})")
    void deleteDish(Long id);

    @Select("select  * from sky_take_out.dish where id = #{id} ")
    Dish getById(Long id);

    void deleteById(List<Long> ids);

    @Update("update dish d set status = #{status} where (id = #{id}) ")
    void uptateStatus(Integer status, Integer id);

    @Select("select d.*from dish d where d.id = #{id}")
    Dish seleteDishById(Long id);

    @Autofill(value = OperationType.UPDATE)
    void updateDish(Dish dish);
    List<Dish> selectList(Dish dish);
}
